package order_service

import (
	"bee/pkg/logging"
	"github.com/go-resty/resty/v2"
	"net/http"
)

// khmc账号名称， zzzh卡号
func (o Order) CreateCash(host, jsessionid string) error {

	url := host + "/nbgl2Web/swgl/saveHkzzInfoAction.do"

	cashData := make(map[string]string)
	cashData["skf"] = "1"
	cashData["khmc"] = o.FullName
	cashData["zzzh"] = o.BankID
	cashData["backUrl"] = ""
	cashData["zzje"] = o.CashNum
	cashData["zzrq"] = "2020-07-15"
	cashData["jtgs"] = "1"
	cashData["xhfId"] = "100121"

	client := resty.New()
	_, err := client.R().SetCookie(&http.Cookie{
		Name:       "JSESSIONID",
		Value:      jsessionid,
		Path:       "/nbgl2Web/",
		Domain:     host,
	}).SetFormData(cashData).Post(url)

	if err != nil {
		return err
	}
	logging.ZapLogger.Infow("【创建流水】", "客户名称", o.CustomerId, "客户银行卡", o.BankID, "traceId", o.TraceId)

	return nil
}